package similarPairs;

public class Solution {
    public int similarPairs(String[] words) {
        int ans = 0;
        for (int i = 0; i < words.length; i++) {
            for (int j = i+1; j < words.length; j++) {
                if(check(words[i],words[j])&&check(words[j],words[i])) {
                    ans++;
                }
            }
        }
        return ans;
    }
    private boolean check(String a,String b) {
        // 判断组成 a和b 的字符是否一样
        for (int i = 0; i < a.length(); i++) {
            if(!b.contains(a.charAt(i)+"")) {
                return false;
            }
        }
        return true;
    }
}
